import packageJson from "./package.json";

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: "2024-04-03",
  devtools: { enabled: true },
  css: ["normalize.css", "~/assets/styles/global.scss"],
  postcss: {
    plugins: {
      "postcss-px-conversion": {
        unitType: "px",
        viewportWidth: 375,
        unitPrecision: 5,
        allowedProperties: ["*"],
        excludedProperties: [],
        viewportUnit: "vw",
        fontViewportUnit: "vw",
        selectorBlacklist: [],
        minPixelValue: 1,
        allowMediaQuery: false,
        replaceRules: true,
        excludeFiles: [],
        includeFiles: [],
        enableLandscape: false,
        landscapeUnit: "vw",
        landscapeViewportWidth: 568,
      },
    },
  },
  runtimeConfig: {
    public: {
      version: packageJson.version,
      // --- 命令行参数 ---
      strategy: process.env.strategy || "113",
      // --- 环境变量 ---

      // --- 环境变量 ---
      apiBaseUrl: "",
      stripeKey: "",
      // googleClientId: process.env.NUXT_PUBLIC_GOOGLE_CLIENT_ID, // 也可以这么写
      // 在环境变量文件中有 NUXT_PUBLIC_ 开头的会被直接注入进来，但是前提是这里也必须定义变量且需要把 NUXT_PUBLIC_ 移除，并且后面转驼峰的
      googleClientId: "",
      clientId: "",
      squareAppId: "",
      squareLocationId: "",
      // --- 环境变量 ---
    },
  },
  modules: [
    "@vant/nuxt",
    [
      "@pinia/nuxt",
      {
        autoImports: [
          // 自动引入 `defineStore()`
          "defineStore",
          // 自动引入 `defineStore()` 并重命名为 `definePiniaStore()`
          ["defineStore", "definePiniaStore"],
        ],
      },
    ],
  ],
  app: {
    head: {
      script: [
        {
          src: "https://unpkg.com/vconsole@latest/dist/vconsole.min.js",
          type: "text/javascript",
        },
        { innerHTML: "new VConsole()" },
      ],
    },
  },

  imports: {
    dirs: [
      // ... 或扫描给定目录中的所有模块
      "composables/**",
    ],
  },
});
